package com.campus.customer.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.campus.common.bean.common.Resp;
import com.campus.customer.entity.GoodsCategory;
import com.campus.customer.service.GoodsCategoryService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 商品分类表 前端控制器
 * </p>
 *
 * @author ZhaoYuJie
 * @since 2025-04-02
 */
@RestController
@RequestMapping("/goodsCategory")
public class GoodsCategoryController {
    @Autowired
    private GoodsCategoryService goodsCategoryService;

    @ApiOperation("根据商户ID查询商品分类列表")
    @GetMapping("/list")
    public Resp<List<GoodsCategory>> list(@ApiParam (value = "商户ID", required = true) @RequestParam("merchantId") Integer merchantId) {
        List<GoodsCategory> list = goodsCategoryService.list(Wrappers.<GoodsCategory>lambdaQuery()
                .eq(GoodsCategory::getMerchantId, merchantId)
                .eq(GoodsCategory::getStatus, true)
                .orderByAsc(GoodsCategory::getSort));
        return Resp.success(list);
    }
}
